package DaEr2_1;

import java.util.Scanner;

public class N_1WeiHe {
    public static void main(String[] args) {
        System.out.println("请输入数：");
        Scanner scanner = new Scanner(System.in);
        int sum = scanner.nextInt();
        int wei=0;
        int sumCopy=sum;
        while (sum!=0){
            wei++;
            sum=sum/10;
        }
        int r=1;
        for (int i = 1; i <= wei-1; i++) {
            r=r*10;
        }

        int sumCopy1=sumCopy%r;
       System.out.println("sumCopy1 = " + sumCopy1);
        int num=0;
        while (sumCopy1!=0) {
            num+=sumCopy1%10;
            sumCopy1/=10;//sumCopy=sumCopy/10;
        }
        System.out.println("num = " + num);
    }
}
